package cloud.maque.conf.common;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
public class CommonProperties {
    /**
     * 线程池配置
     */
    private ThreadPool threadPool = new ThreadPool();
    
    /**
     * 跨域配置
     */
    private Cors cors = new Cors();
    
    @Data
    public static class ThreadPool {
        /**
         * 核心线程数
         */
        private int coreSize = 10;
        
        /**
         * 最大线程数
         */
        private int maxSize = 20;
        
        /**
         * 队列容量
         */
        private int queueCapacity = 200;
        
        /**
         * 线程存活时间（秒）
         */
        private int keepAliveSeconds = 60;
    }
    
    @Data
    public static class Cors {
        /**
         * 允许的源
         */
        private String[] allowedOrigins = {"*"};
        
        /**
         * 允许的方法
         */
        private String[] allowedMethods = {"*"};
        
        /**
         * 允许的头
         */
        private String[] allowedHeaders = {"*"};
        
        /**
         * 是否允许凭证
         */
        private boolean allowCredentials = true;
        
        /**
         * 预检请求的有效期（秒）
         */
        private long maxAge = 3600;
    }
}